import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _isEmpty from "lodash/isEmpty";
import _toSafeInteger from "lodash/toSafeInteger";

var _dec, _class;

/**
 * Form - 菜单编辑-表单
 * @date: 2019-6-27

 * @version: 0.0.5

 */
import React, { PureComponent } from 'react';
import { Form, Input, InputNumber, Select, Switch } from 'antd';
import Lov from 'components/Lov';
import TLEditor from 'components/TLEditor';
import IconsPicker from 'components/IconsPicker';
import intl from 'utils/intl';
import { CODE_LOWER } from 'utils/regExp';
import { MODAL_FORM_ITEM_LAYOUT } from 'utils/constants';
import { isTenantRoleLevel } from 'utils/utils';
import ParentDirInput from "./ParentDirInput";
import DirModal from "./DirModal";
var FormItem = Form.Item;
var TextArea = Input.TextArea;
var Option = Select.Option;
var viewMessagePrompt = 'ciam.tenantMenu.view.message';
var modelPrompt = 'ciam.tenantMenu.model.tenantMenu';
var commonPrompt = 'cpaas.common';
var tenantRoleLevel = isTenantRoleLevel();
var EditorForm = (_dec = Form.create({
  fieldNameProp: null
}), _dec(_class = /*#__PURE__*/function (_PureComponent) {
  _inherits(EditorForm, _PureComponent);

  var _super = _createSuper(EditorForm);

  function EditorForm(props) {
    var _this;

    _classCallCheck(this, EditorForm);

    _this = _super.call(this, props);
    _this.state = {
      dirModelDataSource: [],
      dirPagination: {},
      dirModelVisible: false,
      currentParentDir: {}
    };
    _this.getMenuType = _this.getMenuType.bind(_assertThisInitialized(_this));
    return _this;
  }

  _createClass(EditorForm, [{
    key: "codeValidator",
    value: function codeValidator(rule, value, callback) {
      var _this$props = this.props,
          _this$props$handleChe = _this$props.handleCheckMenuDirExists,
          handleCheckMenuDirExists = _this$props$handleChe === void 0 ? function (e) {
        return e;
      } : _this$props$handleChe,
          organizationId = _this$props.organizationId,
          _this$props$form$getF = _this$props.form.getFieldsValue,
          getFieldsValue = _this$props$form$getF === void 0 ? function (e) {
        return e;
      } : _this$props$form$getF;

      var _getFieldsValue = getFieldsValue(),
          level = _getFieldsValue.level,
          type = _getFieldsValue.type,
          codePrefix = _getFieldsValue.codePrefix;

      handleCheckMenuDirExists({
        code: "".concat(codePrefix, ".").concat(value),
        level: level,
        type: type,
        tenantId: organizationId
      }).then(function (res) {
        if (res && res.failed) {
          callback(res.message);
        }

        callback();
      });
    }
  }, {
    key: "codePrefixValidator",
    value: function codePrefixValidator() {
      this.props.form.validateFields(['code'], {
        force: true
      });
    }
  }, {
    key: "onDirModalOk",
    value: function onDirModalOk(record) {
      var _this2 = this;

      var _this$props2 = this.props,
          _this$props2$form$set = _this$props2.form.setFieldsValue,
          setFieldsValue = _this$props2$form$set === void 0 ? function (e) {
        return e;
      } : _this$props2$form$set,
          isCopy = _this$props2.isCopy;
      this.setState({
        currentParentDir: record
      });

      if (isCopy && record.code) {
        setFieldsValue({
          codePrefix: "".concat(record.code, ".")
        }, function () {
          _this2.props.form.validateFields(['code'], {
            force: true
          });
        });
      }

      setFieldsValue({
        parentId: record.id
      });
    }
  }, {
    key: "openDirModal",
    value: function openDirModal() {
      var _this$props$form$getF2 = this.props.form.getFieldValue,
          getFieldValue = _this$props$form$getF2 === void 0 ? function (e) {
        return e;
      } : _this$props$form$getF2;
      var params = tenantRoleLevel ? {
        size: 10,
        page: 0
      } : {
        size: 10,
        page: 0,
        level: getFieldValue('level')
      };
      this.handleSearch(params); // handleQueryDir({
      //   size: 10,
      //   page: 0,
      //   level: getFieldValue('level') }, dirModelDataSource => {
      //     const { dataSource, pagination } = dirModelDataSource;
      //     this.setState({
      //       dirModelDataSource: dataSource,
      //       dirPagination: pagination,
      //     });
      // });

      this.setState({
        dirModelVisible: true
      });
    }
  }, {
    key: "closeDirModal",
    value: function closeDirModal() {
      this.setState({
        dirModelVisible: false
      });
    }
  }, {
    key: "getMenuType",
    value: function getMenuType() {
      return [{
        value: 'menu',
        title: intl.get("".concat(viewMessagePrompt, ".menu.menu")).d('菜单')
      }, {
        value: 'dir',
        title: intl.get("".concat(viewMessagePrompt, ".menu.dir")).d('目录')
      }, {
        value: 'root',
        title: intl.get("".concat(viewMessagePrompt, ".menu.root")).d('预置目录')
      }];
    }
  }, {
    key: "onLevelChange",
    value: function onLevelChange() {
      var _this$props3 = this.props,
          _this$props3$form$set = _this$props3.form.setFields,
          setFields = _this$props3$form$set === void 0 ? function (e) {
        return e;
      } : _this$props3$form$set,
          _this$props3$handleSe = _this$props3.handleSetDataSource,
          handleSetDataSource = _this$props3$handleSe === void 0 ? function (e) {
        return e;
      } : _this$props3$handleSe;
      setFields({
        parentId: {
          value: undefined,
          error: undefined
        }
      });
      this.setState({
        currentParentDir: {}
      });
      handleSetDataSource({
        permissions: [],
        parentId: null,
        parentName: null
      });
    }
  }, {
    key: "onTypeChange",
    value: function onTypeChange(type) {
      var _this$props4 = this.props,
          _this$props4$dataSour = _this$props4.dataSource,
          dataSource = _this$props4$dataSour === void 0 ? {} : _this$props4$dataSour,
          _this$props4$form = _this$props4.form,
          _this$props4$form$set = _this$props4$form.setFields,
          setFields = _this$props4$form$set === void 0 ? function (e) {
        return e;
      } : _this$props4$form$set,
          _this$props4$form$set2 = _this$props4$form.setFieldsValue,
          setFieldsValue = _this$props4$form$set2 === void 0 ? function (e) {
        return e;
      } : _this$props4$form$set2,
          _this$props4$handleSe = _this$props4.handleSetDataSource,
          handleSetDataSource = _this$props4$handleSe === void 0 ? function (e) {
        return e;
      } : _this$props4$handleSe,
          _this$props4$menuPref = _this$props4.menuPrefixList,
          menuPrefixList = _this$props4$menuPref === void 0 ? [] : _this$props4$menuPref;
      var parentName = dataSource.parentName,
          parentId = dataSource.parentId,
          code = dataSource.code;
      setFieldsValue({
        codePrefix: type === 'root' ? menuPrefixList.length > 0 && menuPrefixList[0].value : code
      });
      setFields({
        dir: {
          error: undefined
        },
        code: {
          value: '',
          error: undefined
        },
        name: {},
        parentId: {
          value: parentId,
          error: undefined
        },
        route: {}
      });
      this.setState({
        currentParentDir: {
          name: parentName
        }
      });
      handleSetDataSource({
        type: type,
        permissions: [],
        parentName: null
      });
    }
  }, {
    key: "parserSort",
    value: function parserSort(value) {
      return _toSafeInteger(value);
    }
  }, {
    key: "handleSearch",
    value: function handleSearch(params) {
      var _this3 = this;

      var _this$props5 = this.props,
          _this$props5$handleQu = _this$props5.handleQueryDir,
          handleQueryDir = _this$props5$handleQu === void 0 ? function (e) {
        return e;
      } : _this$props5$handleQu,
          _this$props5$form$get = _this$props5.form.getFieldValue,
          getFieldValue = _this$props5$form$get === void 0 ? function (e) {
        return e;
      } : _this$props5$form$get;
      var fields = tenantRoleLevel ? {
        size: 10,
        page: 0
      } : {
        size: 10,
        page: 0,
        level: getFieldValue('level')
      };
      handleQueryDir(_objectSpread(_objectSpread({}, fields), params), function (dirModelDataSource) {
        var dataSource = dirModelDataSource.dataSource,
            pagination = dirModelDataSource.pagination;

        _this3.setState({
          dirModelDataSource: dataSource,
          dirPagination: pagination
        });
      });
    }
  }, {
    key: "handleDeselect",
    value: function handleDeselect(value) {
      var _this4 = this;

      var _this$props$menuLabel = this.props.menuLabels,
          menuLabels = _this$props$menuLabel === void 0 ? [] : _this$props$menuLabel;

      if (!_isEmpty(menuLabels)) {
        var temp = menuLabels.filter(function (item) {
          return item.label.name === value;
        });

        if (temp[0] && temp[0].assignType === 'A') {
          var labels = this.props.form.getFieldValue('labels');
          setTimeout(function () {
            _this4.props.form.setFieldsValue({
              labels: labels
            });
          }, 0);
        }
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props6 = this.props,
          _this$props6$form = _this$props6.form,
          _this$props6$form$get = _this$props6$form.getFieldDecorator,
          getFieldDecorator = _this$props6$form$get === void 0 ? function (e) {
        return e;
      } : _this$props6$form$get,
          _this$props6$form$get2 = _this$props6$form.getFieldValue,
          getFieldValue = _this$props6$form$get2 === void 0 ? function (e) {
        return e;
      } : _this$props6$form$get2,
          _this$props6$form$get3 = _this$props6$form.getFieldsValue,
          getFieldsValue = _this$props6$form$get3 === void 0 ? function (e) {
        return e;
      } : _this$props6$form$get3,
          editable = _this$props6.editable,
          _this$props6$dataSour = _this$props6.dataSource,
          dataSource = _this$props6$dataSour === void 0 ? {} : _this$props6$dataSour,
          _this$props6$dirModal = _this$props6.dirModalLoading,
          dirModalLoading = _this$props6$dirModal === void 0 ? false : _this$props6$dirModal,
          _this$props6$menuPref = _this$props6.menuPrefixList,
          menuPrefixList = _this$props6$menuPref === void 0 ? [] : _this$props6$menuPref,
          _this$props6$menuType = _this$props6.menuTypeList,
          menuTypeList = _this$props6$menuType === void 0 ? [] : _this$props6$menuType,
          isCopy = _this$props6.isCopy,
          recordCreateFlag = _this$props6.recordCreateFlag,
          isEdit = _this$props6.isEdit,
          siteLabelList = _this$props6.siteLabelList,
          tenantLabelList = _this$props6.tenantLabelList,
          menuLabels = _this$props6.menuLabels;
      var _this$state = this.state,
          dirModelVisible = _this$state.dirModelVisible,
          currentParentDir = _this$state.currentParentDir,
          _this$state$dirModelD = _this$state.dirModelDataSource,
          dirModelDataSource = _this$state$dirModelD === void 0 ? [] : _this$state$dirModelD,
          _this$state$dirPagina = _this$state.dirPagination,
          dirPagination = _this$state$dirPagina === void 0 ? {} : _this$state$dirPagina;
      var description = dataSource.description,
          icon = dataSource.icon,
          parentId = dataSource.parentId,
          _dataSource$tenantId = dataSource.tenantId,
          tenantId = _dataSource$tenantId === void 0 ? null : _dataSource$tenantId,
          name = dataSource.name,
          parentName = dataSource.parentName,
          _dataSource$type = dataSource.type,
          type = _dataSource$type === void 0 ? '' : _dataSource$type,
          quickIndex = dataSource.quickIndex,
          route = dataSource.route,
          sort = dataSource.sort,
          levelPath = dataSource.levelPath,
          _dataSource$virtualFl = dataSource.virtualFlag,
          virtualFlag = _dataSource$virtualFl === void 0 ? 0 : _dataSource$virtualFl,
          _token = dataSource._token,
          code = dataSource.code,
          tenantName = dataSource.tenantName;
      var dirModalProps = {
        getFieldsValue: getFieldsValue,
        visible: dirModelVisible,
        onOk: this.onDirModalOk.bind(this),
        onCancel: this.closeDirModal.bind(this),
        dataSource: dirModelDataSource,
        pagination: dirPagination,
        defaultSelectedRow: {
          id: getFieldValue('parentId'),
          name: currentParentDir.name
        },
        handleSearch: this.handleSearch.bind(this),
        loading: dirModalLoading
      }; // 区分行上编辑，新建，过滤类别

      var menuFilterTypeList = _toConsumableArray(menuTypeList);

      if (!editable) {
        if (recordCreateFlag) {
          // eslint-disable-next-line no-nested-ternary
          menuFilterTypeList = isCopy ? type === 'dir' ? menuTypeList.filter(function (item) {
            return item.value === 'root' || item.value === 'dir';
          }) // 复制的是自设目录时，可创建为根目录或自设目录，其他只能创建相同的类别
          : menuTypeList.filter(function (item) {
            return item.value === type;
          }) : menuTypeList.filter(function (item) {
            return item.value !== 'root';
          });
        } else {
          menuFilterTypeList = menuTypeList.filter(function (item) {
            return item.value === 'root';
          });
        }
      }

      var parentCode;

      if (levelPath) {
        var pathArr = levelPath.split('|');
        parentCode = pathArr[pathArr.length - 2];
      }

      var initialValue;

      if (isCopy) {
        if (levelPath) {
          var _pathArr = levelPath.split('|');

          parentCode = _pathArr[_pathArr.length - 2];
        }

        menuPrefixList.forEach(function (item) {
          if (code.startsWith(item.value)) {
            parentCode = item.value;
          }
        });
        initialValue = type === 'root' || getFieldValue('type') === 'root' ? menuPrefixList.length > 0 && menuPrefixList[0].value : parentCode;
      } else {
        initialValue = recordCreateFlag ? "".concat(code, ".") : menuPrefixList.length > 0 && menuPrefixList[0].value;
      }

      var selectBefore = getFieldDecorator('codePrefix', {
        initialValue: initialValue,
        // validateTrigger: 'onSelect',
        rules: [{
          validator: this.codePrefixValidator.bind(this)
        }] // validateFirst: true,

      })( /*#__PURE__*/React.createElement(Select, {
        disabled: getFieldValue('type') !== 'root',
        style: {
          width: 'auto'
        }
      }, menuPrefixList.map(function (n) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          key: n.value,
          value: n.value
        }, n.meaning, ".");
      })));
      var defaultPrompt = {
        root: {
          code: intl.get("".concat(modelPrompt, ".dirCode")).d('目录编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".dirCode")).d('目录编码')
          }),
          name: intl.get("".concat(modelPrompt, ".dirName")).d('目录名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".dirName")).d('目录名称')
          })
        },
        link: {
          code: intl.get("".concat(modelPrompt, ".linkCode")).d('链接编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".linkCode")).d('链接编码')
          }),
          name: intl.get("".concat(modelPrompt, ".linkName")).d('链接名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".linkName")).d('链接名称')
          }),
          parentName: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录'),
          parentNameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录')
          }),
          routeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".route")).d('路由')
          })
        },
        'inner-link': {
          code: intl.get("".concat(modelPrompt, ".linkCode")).d('链接编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".linkCode")).d('链接编码')
          }),
          name: intl.get("".concat(modelPrompt, ".linkName")).d('链接名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".linkName")).d('链接名称')
          }),
          parentName: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录'),
          parentNameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录')
          }),
          routeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".route")).d('路由')
          })
        },
        window: {
          code: intl.get("".concat(modelPrompt, ".windowCode")).d('窗口编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".windowCode")).d('窗口编码')
          }),
          name: intl.get("".concat(modelPrompt, ".windowName")).d('窗口名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".\u7A97\u53E3Name")).d('窗口名称')
          }),
          parentName: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录'),
          parentNameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录')
          }),
          routeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".route")).d('路由')
          })
        },
        dir: {
          code: intl.get("".concat(modelPrompt, ".dirCode")).d('目录编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".dirCode")).d('目录编码')
          }),
          name: intl.get("".concat(modelPrompt, ".dirName")).d('目录名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".dirName")).d('目录名称')
          }),
          parentName: intl.get("".concat(modelPrompt, ".parentName")).d('上级目录'),
          parentNameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".parentName")).d('上级目录')
          }),
          routeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".route")).d('路由')
          })
        },
        menu: {
          code: intl.get("".concat(modelPrompt, ".menuCode")).d('菜单编码'),
          codeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".menuCode")).d('菜单编码')
          }),
          name: intl.get("".concat(modelPrompt, ".menuName")).d('菜单名称'),
          nameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".menuName")).d('菜单名称')
          }),
          parentName: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录'),
          parentNameMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".ownDir")).d('所属目录')
          }),
          routeMessage: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".route")).d('路由')
          })
        }
      };
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".type")).d('类别')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('type', {
        initialValue: type,
        rules: [{
          required: true,
          message: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".type")).d('类别')
          })
        }]
      })( /*#__PURE__*/React.createElement(Select, {
        disabled: editable,
        onChange: this.onTypeChange.bind(this)
      }, menuFilterTypeList.map(function (n) {
        return /*#__PURE__*/React.createElement(Option, {
          key: n.value,
          value: n.value
        }, n.meaning);
      })))), isCopy && /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".tenantId")).d('租户')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('selectedTenantId', {
        initialValue: tenantId,
        rules: [{
          required: true,
          message: intl.get("".concat(commonPrompt, ".validation.notNull"), {
            name: intl.get("".concat(modelPrompt, ".tenantId")).d('租户')
          })
        }]
      })( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.TENANT",
        textValue: tenantName
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: defaultPrompt[type].code,
        required: true
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('code', _objectSpread({
        initialValue: recordCreateFlag ? undefined : code
      }, !editable ? {
        validateFirst: true,
        validateTrigger: 'onBlur',
        rules: [{
          required: true,
          message: defaultPrompt[type].codeMessage
        }, {
          pattern: CODE_LOWER,
          message: intl.get('cpaas.common.validation.codeLower').d('全小写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
        }, {
          max: 128 - (getFieldValue('codePrefix') ? getFieldValue('codePrefix').length : 0) - 1,
          message: intl.get('cpaas.common.validation.max', {
            max: 128
          })
        }, {
          validator: this.codeValidator.bind(this)
        }]
      } : {}))( /*#__PURE__*/React.createElement(Input, {
        trim: true,
        inputChinese: false,
        addonBefore: editable ? null : selectBefore,
        disabled: editable
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: defaultPrompt[type].name
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('name', {
        initialValue: name,
        rules: [{
          required: true,
          message: defaultPrompt[type].nameMessage
        }, {
          max: 64,
          message: intl.get("".concat(commonPrompt, ".validation.max"), {
            max: 64
          }).d("\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7".concat(64, "\u4E2A\u5B57\u7B26"))
        }]
      })( /*#__PURE__*/React.createElement(TLEditor, {
        label: defaultPrompt[type].name,
        field: "name",
        inputSize: {
          zh: 64,
          en: 64
        },
        token: _token,
        disabled: editable && !isEdit
      }))), type !== 'root' && getFieldValue('type') !== 'root' && /*#__PURE__*/React.createElement(FormItem, Object.assign({
        required: true,
        label: defaultPrompt[type].parentName
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('parentId', {
        initialValue: parentId,
        validateFirst: true,
        validate: [{
          rules: [{
            message: defaultPrompt[type].parentNameMessage,
            required: true
          }]
        }]
      })( /*#__PURE__*/React.createElement(ParentDirInput, {
        textValue: currentParentDir.name || parentName,
        onClick: this.openDirModal.bind(this),
        disabled: editable
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".quickIndex")).d('快速索引')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('quickIndex', {
        initialValue: quickIndex,
        rules: [{
          max: 30,
          message: intl.get("".concat(commonPrompt, ".validation.max"), {
            max: 30
          })
        }, {
          pattern: /^[a-zA-Z0-9]*$/,
          message: intl.get('ciam.tenantMenu.view.validation.quickIndex').d('快速索引只能由字母和数字组成')
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        inputChinese: false,
        disabled: editable && !isEdit
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".route")).d('路由')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('route', _objectSpread({
        initialValue: route,
        rules: [{
          max: 1000,
          message: intl.get("".concat(commonPrompt, ".validation.max"), {
            max: 1000
          }).d("\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7".concat(1000, "\u4E2A\u5B57\u7B26"))
        }]
      }, type === 'menu' || type === 'link' || type === 'inner-link' ? {
        rules: [{
          required: true,
          message: defaultPrompt[type].routeMessage
        }, {
          max: 1000,
          message: intl.get("".concat(commonPrompt, ".validation.max"), {
            max: 1000
          }).d("\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7".concat(1000, "\u4E2A\u5B57\u7B26"))
        }]
      } : {}))( /*#__PURE__*/React.createElement(Input, {
        disabled: editable && !isEdit
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".sort")).d('序号')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('sort', {
        initialValue: sort || 0
      })( /*#__PURE__*/React.createElement(InputNumber, {
        min: 0,
        step: 1,
        parser: this.parserSort.bind(this),
        disabled: editable && !isEdit
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".icon")).d('图标')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('icon', {
        initialValue: icon
      })( /*#__PURE__*/React.createElement(IconsPicker, {
        field: "icon",
        allowClear: true,
        isButton: true,
        disabled: editable && !isEdit
      }))), type === 'menu' && /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".virtualFlag")).d('是否虚拟菜单')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('virtualFlag', {
        initialValue: virtualFlag === 1,
        valuePropName: 'checked'
      })( /*#__PURE__*/React.createElement(Switch, {
        disabled: editable && !isEdit
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".label")).d('菜单标签')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('labels', {
        initialValue: menuLabels.map(function (item) {
          return item.label.name;
        }) || []
      })( /*#__PURE__*/React.createElement(Select, {
        disabled: editable && !isEdit,
        mode: "multiple",
        onDeselect: this.handleDeselect.bind(this)
      }, (getFieldValue('level') === 'site' ? siteLabelList : tenantLabelList).map(function (n) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          key: n.name,
          value: n.name
        }, n.name);
      })))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: intl.get("".concat(modelPrompt, ".description")).d('描述')
      }, MODAL_FORM_ITEM_LAYOUT), getFieldDecorator('description', {
        initialValue: description,
        rules: [{
          max: 300,
          message: intl.get("".concat(commonPrompt, ".validation.max"), {
            max: 300
          }).d("\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7".concat(300, "\u4E2A\u5B57\u7B26"))
        }]
      })( /*#__PURE__*/React.createElement(TextArea, {
        autosize: true,
        disabled: editable && !isEdit
      })))), /*#__PURE__*/React.createElement(DirModal, dirModalProps));
    }
  }]);

  return EditorForm;
}(PureComponent)) || _class);
export { EditorForm as default };